﻿@model GPS.ENTITYS.ViewModelDKH_LH1
@using PagedList.Mvc;
@using GPS.Helpers;
@{
    ViewBag.Title = "Lịch học";
}

<style type="text/css">
    .table-condensed thead {
        background-color: rgba(243, 112, 44, 1);
        color: white;
    }

        .table-condensed thead th {
            /*background: rgba(243, 112, 44, 1);*/
            color: #FCFFFF;
            cursor: pointer;
            white-space: nowrap;
            padding: 3px 6px 5px;
            border: 1px solid #FF6600;
            background: #94b6e8 url(../fonts/bgr_title_So.gif) repeat-x center top;
            overflow: hidden;
            font-weight: bold;
            text-align: center;
        }

        .table-condensed thead tr th {
            border: 1px solid #FF6600;
        }
</style>

<div class="container fdb-div-content fdb-div-corner-all">
    <h3 class="text-center fdb-title-search-form">Tra cứu Theo dõi quản lý lịch học thực hành</h3>
    <div class="row">
        @using (Html.BeginForm("Search", "GPS_LichHoc_TH", FormMethod.Get))
        {
            <div class="list-group">
                <fieldset class="fs_body">
                    <legend class="head_title">Điều Kiện Tìm Kiếm</legend>
                    <div class="criteria_search">
                        <div class="row margin-top-05">
                            <div class="col-md-2 control-label">
                                Đơn vị đào tạo
                            </div>
                            <div class="col-md-4">
                                @Html.DropDownListFor(model => model.KH_LH_DVGTVT_MA, (SelectList)ViewBag.DVGTVT_MAs, "---Lựa chọn--", new { @class = "form-control", @id = "DVGTVT_MA_dll" })
                            </div>
                            <div class="col-md-2 control-label">
                                Khóa đào tạo
                            </div>
                            <div class="col-md-4">
                                @Html.DropDownListFor(model => model.KH_LH_KH_MA, (SelectList)ViewBag.KH_MAs, string.Empty, new { @title = "Vui lòng chọn khóa học...", @id = "KH_MA_dll", @style = "font-weight:bold;width:300px" })
                            </div>
                        </div>

                        <div class="row margin-top-05">
                            <div class="col-md-2 control-label">
                                Phương tiện
                            </div>
                            <div class="col-md-4">
                                @Html.DropDownListFor(model => model.KH_LH_PT_BIENSO, (SelectList)ViewBag.PT_MAs, string.Empty, new { @class = "form-control", @id = "KH_LH_PT_BIENSO" })

                            </div>
                            <div class="col-md-2 control-label">
                                Giảng viên
                            </div>
                            <div class="col-md-4">
                                @Html.DropDownListFor(model => model.KH_LH_GV_MA, (SelectList)ViewBag.GV_MAs, string.Empty, new { @class = "form-control", @id = "KH_LH_GV_MA" })

                            </div>

                        </div>

                        <div class="row margin-top-05">

                            <div class="col-md-2 control-label">
                                Hạng đào tạo
                            </div>
                            <div class="col-md-4">
                                @Html.DropDownListFor(model => model.HANGDT_MA, (SelectList)ViewBag.HANGDT_MAs, string.Empty, new { @class = "form-control", @id = "HANGDT_MA_dll" })
                            </div>
                        </div>

                        <div class="row">
                            <div class="col-md-2 control-label">
                                Ngày học từ ngày
                            </div>
                            <div class="col-md-4">

                                @Html.TextBoxFor(model => model.KH_LH_TUNGAY, "{0:dd/MM/yyyy}", new { @class = "form-control", @style = "width:120px" })
                            </div>

                            <div class="col-md-2 control-label">
                                Ngày học đến ngày
                            </div>
                            <div class="col-md-4">
                                @Html.TextBoxFor(model => model.KH_LH_DENNGAY, "{0:dd/MM/yyyy}", new { @class = "form-control", @style = "width:120px" })

                            </div>
                        </div>

                    </div>

                    <p class="margin-top-05">
                        <button type="submit" class="btn btn-primary btn-sm">
                            <span class="glyphicon glyphicon-search"></span> Tìm kiếm
                        </button>
                    </p>

                </fieldset>
            </div>
        }

        <div class="row">
            <fieldset class="fs_body">
                <legend class="head_title">Kết quả tìm kiếm</legend>


                <div class="row margin-top-05">
                    <div class="divbtnFielset">
                        <div style="float: right;">
                            <label id="lblMessageTotal" style="color:blue; font-weight:bold">Tổng số bản ghi: @ViewBag.TotalRow</label>
                        </div>
                    </div>
                </div>
                <table class="table table-hover table-bordered table-condensed">
                    <thead>
                        <tr>
                            <th>
                                STT
                            </th>
                            <th>
                                Khóa học
                            </th>
                            <th>
                                Biển số xe
                            </th>
                            <th>
                                Đơn vị GTVT
                            </th>
                            <th>
                                Tháng
                            </th>
                            <th>
                                Tuần
                            </th>
                            <th>
                                Từ ngày
                            </th>
                            <th>
                                Đến ngày
                            </th>
                            <th>
                                Giáo viên
                            </th>
                            <th>
                                Giai đoạn
                            </th>

                            <th>
                                Thao tác
                            </th>
                        </tr>
                    </thead>
                    <tbody class="tbody">
                        @{
                            int i = 0;
                            foreach (var item in Model.SearchResults)
                            {
                                <tr>
                                    <td>
                                        @(i + 1)
                                    </td>
                                    <td>
                                        @Html.DisplayFor(modelItem => item.KH_TEN)
                                    </td>
                                    <td>
                                        <a href="@Url.Action("HocVienPhuongTien", "GPS_LichHoc", new { id = item.KH_LH_KH_MA, id2 = HttpUtility.HtmlEncode(item.KH_LH_PT_BIENSO) })" data-modal="" title="Click vào để xem danh sách học viên">

                                            @item.KH_LH_PT_BIENSO
                                        </a>
                                    </td>
                                    <td>

                                        @Html.DisplayFor(modelItem => item.DVGTVT_TEN)
                                    </td>
                                    <td>
                                        @{
                                var LH_THANG = Convert.ToInt32(item.KH_LH_THANG);
                                @Html.Raw(LH_THANG);
                                        }

                                    </td>
                                    <td>
                                        @{
                                var LH_TUAN = Convert.ToInt32(item.KH_LH_TUAN);
                                @Html.Raw(LH_TUAN);
                                        }

                                    </td>
                                    <td>
                                        @Html.DisplayFor(modelItem => item.KH_LH_TUNGAY)
                                    </td>
                                    <td>
                                        @Html.DisplayFor(modelItem => item.KH_LH_DENNGAY)
                                    </td>
                                    <td>
                                        @Html.DisplayFor(modelItem => item.GV_HOTEN)
                                    </td>
                                    <td align="center">
                                      
                                            @Html.DisplayFor(modelItem => item.KH_LH_GDOAN_MA)
                                       

                                    </td>
                                    <td>
                                        @*@Html.Raw("<a data-modal='' href='/GPS_LichHoc_TH/detail/" + item.ID_TH + "' id='" + item.ID_TH + "' title='Chi tiết'> <span class='glyphicon glyphicon-search'> </span> </a>")*@
                                    </td>

                                </tr>
                                                  i++;
                            }

                        }


                    </tbody>
                </table>





                <div id="contentPager">
                    @Html.PagedListPager(Model.SearchResults, page => Url.Action("Search", new
                       {
                           page,
                           Model.KH_LH_DVGTVT_MA,
                           Model.KH_LH_KH_MA,
                           Model.KH_LH_PT_BIENSO,
                           Model.KH_LH_GV_MA,
                           Model.HANGDT_MA,
                           Model.KH_LH_TUNGAY,
                           Model.KH_LH_DENNGAY
                       }))
                </div>

            </fieldset>
        </div>
    </div>
</div>

<div id="wait" style="display: none; position:absolute; top: 10%; right: 10%; padding: 2px; z-index: 99999">
    <img src="~/fonts/images/loading16.gif" width="65" height="65" />
</div>
<!-- Modal -->

<div id='myModal' class='modal fade in'>
    <div class="modal-dialog">
        <div class="modal-content">
            <div id='myModalContent'></div>
        </div>
    </div>
</div>

<div id='myModal2' class='modal fade in'>
    <div class="modal-dialog">
        <div class="modal-content">
            <div id='myModalContent2'></div>
        </div>
    </div>
</div>

<!-- Modal Start here-->
<div class="modal fade bs-example-modal-sm" id="pleaseWaitDialog" tabindex="-1"
     role="dialog" aria-hidden="true" data-backdrop="static">
    <div class="modal-dialog modal-sm" style="top:50%">
        <div class="modal-content" style="margin: 0 auto;width:300px">
            <div class="modal-header">
                <h4 class="modal-title">
                    <span class="glyphicon glyphicon-time">
                    </span>Đang xử lý...
                </h4>
            </div>
            <div class="modal-body">
                <div class="progress">
                    <div class="progress-bar progress-bar-info
                    progress-bar-striped active"
                         style="width: 100%">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<link href="~/dist/css/bootstrap-select.css" rel="stylesheet" />
<script src="~/dist/js/bootstrap-select.js"></script>

<script src="~/Scripts/datepicker.js"></script>
<script src="~/Scripts/jquery-ui-1.11.4.js"></script>
<script src="//code.jquery.com/ui/1.11.2/jquery-ui.js" type="text/javascript"></script>
<script src="~/Scripts/datepicker.js"></script>
<script src="~/Scripts/jquery-ui-1.11.4.js"></script>
<script src="~/Scripts/jquery.maskedinput.js"></script>
<script src="~/Scripts/jquery.maskMoney.js"></script>
<script src="~/Scripts/jquery.number.js"></script>
<script src="~/Scripts/jquery.masknumber.js"></script>

<link href="~/Scripts/select2.css" rel="stylesheet" />
<link href="~/Scripts/select2.min.css" rel="stylesheet" />
<script src="~/Scripts/select2.js"></script>

<script type="text/javascript">

    $("#KH_LH_TUNGAY").datepicker({
        changeMonth: true,
        changeYear: true,

        dateFormat: 'dd/mm/yy'
    });
    $("#KH_LH_TUNGAY").mask("99/99/9999", { placeholder: "dd/mm/yyyy" });

    $("#KH_LH_DENNGAY").datepicker({
        changeMonth: true,
        changeYear: true,

        dateFormat: 'dd/mm/yy'
    });
    $("#KH_LH_DENNGAY").mask("99/99/9999", { placeholder: "dd/mm/yyyy" });


    $(function () {
        $(document).tooltip();
    });

</script>

<!-- Modal ends Here -->
<script type="text/javascript">


    //$('.selectpicker').selectpicker({
    //    liveSearch: true,
    //    showSubtext: true
    //});

    $(document).ready(function () {

        var pageSize = 20;
        var optionListUrl = '@Url.Action("Select2KH_MA_LH_TraCuu", "GPS_Ajax")';

        $('#KH_MA_dll').select2(
                {
                    ajax: {
                        delay: 50,
                        url: optionListUrl,
                        dataType: 'json',

                        data: function (params) {
                            /// params.page = params.page || 1;
                            return {
                                searchTerm: params.term,
                                dvgtvt_ma: $("#DVGTVT_MA_dll").val()
                                //pageNumber: params.page results: JSON.parse(data)
                            };
                        },
                        processResults: function (data, params) {

                            return {
                                results: data.Results
                            };
                        }
                    },
                    placeholder: "-- Chọn khóa học --",
                    minimumInputLength: 2,
                    allowClear: true,
                    language: { inputTooShort: function () { return 'Nhập lớn hơn 2 ký tự để tìm kiếm khóa học'; } }
                });

        @*$("#DVGTVT_MA_dll").on("change", function () {
            // lstBoxPhuongTien
            var position = $(this).position();

            $("#wait").attr("style", "display:block;position:absolute;top:40%;left:50%;padding:2px; z-index:99999");

            $.ajax({
                url: '@Url.Action("getKH_MAs3", "GPS_LichHoc_TH")',
                type: 'POST',
                traditional: true,
                data: {
                    ma_DVGT: $('#DVGTVT_MA_dll').val()
                },
                dataType: 'json',
                success: function (data) {

                    var a = '<option value></option>' + data.pts.strKhoaHoc;
                    $("#KH_MA_dll").html(a);
                    $('#KH_MA_dll').selectpicker('refresh');

                    var c = '<option value></option>' + data.pts.strphuongtien;
                    $('#KH_LH_PT_BIENSO').html(c);

                    var b = '<option value></option>' + data.pts.strgiangvien;
                    $('#KH_LH_GV_MA').html(b);

                    $("#wait").attr("style", "display:none;position:absolute;top:25%;left:50%;padding:2px; z-index:99999");
                },
                error: function () {

                    alert("Lỗi kết nối với server!");
                    $("#wait").attr("style", "display:none;position:absolute;top:20%;left:50%;padding:2px; z-index:99999");

                }
            });


        });*@

        $("#KH_MA_dll").on("change", function () {
            // lstBoxPhuongTien
            var position = $(this).position();

            $("#wait").attr("style", "display:block;position:absolute;top:40%;left:50%;padding:2px; z-index:99999");
            $.ajax({
                url: '@Url.Action("getPT_IN_KH_MAs3", "GPS_LichHoc_TH")',
                type: 'post',
                data: {
                    Ma_DVGT: $('#DVGTVT_MA_dll').val(),
                    Ma_KH: $(this).val()
                }
            }).done(function (response) {
                // update district by province
                var a = '<option value></option>' + response;   // defaut value
                $("#KH_LH_PT_BIENSO").html(a);
                $("#wait").attr("style", "display:none;position:absolute;top:40%;left:50%;padding:2px; z-index:99999");
            });

            $.ajax({
                url: '@Url.Action("getGV_IN_KH_MAs3", "GPS_LichHoc_TH")',
                type: 'post',
                data: {
                    Ma_DVGT: $('#DVGTVT_MA_dll').val(),
                    Ma_KH: $(this).val()
                }
            }).done(function (response) {
                // update district by province
                var a = '<option value></option>' + response;   // defaut value
                $("#KH_LH_GV_MA").html(a);
                $("#wait").attr("style", "display:none;position:absolute;top:40%;left:50%;padding:2px; z-index:99999");
            });


        });

        $("#KH_LH_PT_BIENSO").on("change", function () {
            // lstBoxPhuongTien
            var position = $(this).position();

            $("#wait").attr("style", "display:block;position:absolute;top:40%;left:50%;padding:2px; z-index:99999");


            $.ajax({
                url: '@Url.Action("GPS_GET_GV_IN_PT3", "GPS_LichHoc_TH")',
                type: 'post',
                data: {
                    Ma_DVGT: $('#DVGTVT_MA_dll').val(),
                    Ma_KH: $("#KH_MA_dll").val(),
                    Ma_PT: $(this).val()
                },
            }).done(function (response) {
                // update district by province
                var a = '<option value></option>' + response;   // defaut value
                $("#KH_LH_GV_MA").html(a);
                $("#wait").attr("style", "display:none;position:absolute;top:40%;left:50%;padding:2px; z-index:99999");
            });



        });

    });

    $(function () {
        $.ajaxSetup({ cache: false });
        $("body").on('click', 'a[data-modal]', function (e) {
            //$("#dvLoading").attr("style", "display:block; height: 100px;width: 100px;position: fixed;left: 50%;top: 50%;margin: -25px 0 0 -25px;z-index: 1000;");
            $('#myModalContent').empty();
            $('#pleaseWaitDialog').modal('show');

            $('#myModalContent').load(this.href, function () {
                $('#myModal').modal({
                    keyboard: true
                }, 'show');
                //$("#dvLoading").attr("style", "display:none; height: 100px;width: 100px;position: fixed;left: 50%;top: 50%;margin: -25px 0 0 -25px;z-index: 1000;");

                $('#pleaseWaitDialog').modal('hide');

            });
            return false;
        });


        $('.selectpicker').selectpicker({
            liveSearch: true,
            showSubtext: true
        });
    });

    $(function () {
        $.ajaxSetup({ cache: false });
        $("body").on('click', '.biensodetail', function (e) {
            //$("#dvLoading").attr("style", "display:block; height: 100px;width: 100px;position: fixed;left: 50%;top: 50%;margin: -25px 0 0 -25px;z-index: 1000;");
            $('#myModalContent2').empty();
            $('#pleaseWaitDialog').modal('show');

            $('#myModalContent2').load(this.href, function () {
                $('#myModal2').modal({
                    keyboard: true
                }, 'show');
                //$("#dvLoading").attr("style", "display:none; height: 100px;width: 100px;position: fixed;left: 50%;top: 50%;margin: -25px 0 0 -25px;z-index: 1000;");

                $('#pleaseWaitDialog').modal('hide');

            });
            return false;
        });

    });

</script>